from models import db

class Order(db.Model):
    __tablename__ = "order"
    id = db.Column(db.Integer,primary_key=True)
    orderdetails = db.relationship('OrderDetail',backref="order",lazy='dynamic')
    user_id = db.Column(db.Integer,db.ForeignKey('user.id'))

    def __repr__(self):
        return self.id


class OrderDetail(db.Model):
    __tablename__ = "orderdetail"
    id = db.Column(db.Integer,primary_key=True)
    order_id = db.Column(db.Integer,db.ForeignKey('order.id'))
    good_id = db.Column(db.Integer,db.ForeignKey('good.id'))

    def __repr__(self):
        return self.id

